import 'package:flutter/material.dart';
import 'package:sharing/model/book.dart';
import 'package:sharing/ui/widget/book_info.dart';
import 'package:sharing/resources/styles.dart';
import 'package:sharing/resources/colors.dart';
import 'package:sharing/model/book_list_item.dart';
import 'package:sharing/utils/whole_apis.dart';

class BookWithName extends StatelessWidget {
  final Book book;
  BookWithName({@required this.book}){

  }

  @override
  Widget build(BuildContext context) {
    print("book $book");
    return GestureDetector(
      onTap: () {
        Navigator.of(context).push(
          MaterialPageRoute(
            builder: (context) => BookInfo(book: book),
          ),
        );
      },
      child: Container(
        height: 144,
//          decoration: BoxDecoration(
//              borderRadius: BorderRadius.all(
//                Radius.circular(4.0),
//              ),
//              border: Border.all(color: AppColor.lightless, width: 1.0)),
//        height: 100,
        width: 100,
        margin: const EdgeInsets.all(4.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            Expanded(
              child: Card(
                elevation: 4.0,
                child: Container(
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(4.0),
                  ),
                  child: Image.network(
                  //  book.url,
                    WholeApis.hostName + "/"+book.cover,

                    fit: BoxFit.cover,
                  ),
                ),
              ),
            ),
            Container(
              height: 16,
              alignment: Alignment.centerLeft,
              margin: const EdgeInsets.only(bottom: 4.0),
              padding: const EdgeInsets.symmetric(horizontal: 4.0),
              child: Text(
                book.name,
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
                style: AppStyles.contextTextStyle,
              ),
            ),
            // 书评
            Container(),
          ],
        ),
      ),
    );
  }
}
